package com.github.edu.repair.manager.entity;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

/**
 * Create by IntelliJ IDEA
 * 用户：王建
 * 日期：2018-8-20
 */
@Entity
@Table(name = "t_bx_lyxx")
public class TBxLyxx implements Serializable {
    private Integer id;
    private String lymc;
    private String sm;
    private Integer ssqy;
    private Integer sfqy;
    private TBxLyqy bxLyqy;
    private String ssqymc;

    @Id
    @Column(name = "id")
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Basic
    @Column(name = "lymc")
    public String getLymc() {
        return lymc;
    }

    public void setLymc(String lymc) {
        this.lymc = lymc;
    }

    @Basic
    @Column(name = "sm")
    public String getSm() {
        return sm;
    }

    public void setSm(String sm) {
        this.sm = sm;
    }

    @Basic
    @Column(name = "ssqy")
    public Integer getSsqy() {
        return ssqy;
    }

    public void setSsqy(Integer ssqy) {
        this.ssqy = ssqy;
    }

    @Basic
    @Column(name = "sfqy")
    public Integer getSfqy() {
        return sfqy;
    }

    public void setSfqy(Integer sfqy) {
        this.sfqy = sfqy;
    }

    @ManyToOne(cascade = {CascadeType.MERGE,CascadeType.REFRESH})
    @JoinColumn(name = "ssqy",referencedColumnName = "id",insertable = false,updatable = false)
    public TBxLyqy getBxLyqy() {
        return bxLyqy;
    }

    public void setBxLyqy(TBxLyqy bxLyqy) {
        if(null!=bxLyqy){
            this.ssqymc=bxLyqy.getQymc();
        }
        this.bxLyqy = bxLyqy;
    }

    @Transient
    public String getSsqymc() {
        return ssqymc;
    }

    public void setSsqymc(String ssqymc) {
        this.ssqymc = ssqymc;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TBxLyxx tBxLyxx = (TBxLyxx) o;
        return Objects.equals(id, tBxLyxx.id) &&
                Objects.equals(lymc, tBxLyxx.lymc) &&
                Objects.equals(sm, tBxLyxx.sm) &&
                Objects.equals(ssqy, tBxLyxx.ssqy) &&
                Objects.equals(sfqy, tBxLyxx.sfqy);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, lymc, sm, ssqy, sfqy);
    }
}
